package com.anycl.design.structural.flyweight.demo;

/**
 * 享元模式
 */
public class Main {

    public static void main(String[] args) {
        // 2个科目，初始化池子
        for (int i = 0; i < 2; i++) {
            String subject = "科目" + i;
            ExamInfoFactory.getExamInfo(subject);
        }
        // 假设3个考生考试
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 2; j++) {
                ExamInfo examInfo = ExamInfoFactory.getExamInfo("科目" + j);
                examInfo.setUser("考生" + i);
                System.out.println(examInfo);
            }
        }

    }
}
